<template>
  <div>
    <div v-for="(item,index) in planRecordData" :key="index" class="planRecordData" >
      <div>{{$moment(item.createDate).format('YYYY-MM-DD')}}:</div>
      <div v-if="currentStyle=='summerNote'" v-html="item.content" class="item"></div>
      <div v-else class="item" >{{item.val}}</div>
      <el-button @click="planPecordClick(item)" type="primary" size="mini">使用</el-button>
    </div>
  </div>
</template>

<script>
  import {data4import} from "@/api/plan.js"
  export default {
    props: ['docItemDefId','currentStyle'],
    data() {
      return {
        planRecordData: [],
      }
    },
    watch: {
      docItemDefId(newValue, oldValue) {
        this.planRecord()
      }
    },
    created() {
      this.planRecord()
    },
    methods: {
      planPecordClick(item) {
        this.$emit('getplanRecordName',item)
      },
      planRecord(){
        data4import({docItemDefId:this.docItemDefId}).then(res=>{
          if(res.code === 200) {
            this.planRecordData = res.data
          }else{
            this.$message.error(res.message)
          }
        })
      }
    },
  }
</script>

<style lang="scss" scoped>
  .planRecordData{
    display: flex;
    align-items: center;
    justify-content: space-between;

    .item{
      text-align: left;
      flex: 1;
      margin: 10px 30px;
      min-height: 80px;
      border-bottom: 1px solid #eeeeee;
    }
  }
</style>
